<?php
	namespace Home\Controller;
	use Think\Controller;

	//执行验证登入注册
	class ActionController extends Controller{
		public function add(){
			$user = D('users');
			$user->create();
			$user->u_trgtime = time();
				/*var_dump($_POST);die;*/
			if($user->add()){
				session('username',$_POST);
				$this->redirect(I('post.model').'/'.I('post.controller'));
			}
			
		}
		public function doName($name){
			$arr['uname']=$name;
			$user = D('users');
			if(!$user->create($arr,1)){
				$this->ajaxReturn(false);			
			}else{
				$this->ajaxReturn(true);
			}			
		}		
		
		public function stop(){
		
			session('username',null);
			$this->redirect(I('get.model').'/'.I('get.controller'));

		}
		public function select($name,$pass){
			$user = D('users');
			$data['uname'] = $name;
	
	 		if( $result = $user->where($data)->select()){

	 			if($result['0']['password'] == MD5($pass)){

	 				if($result['0']['u_status'] != 0){
	 					$this->ajaxReturn('3');
	 				}
	 				session('username',$result[0]);

	 				$this->ajaxReturn('0');
	 			} else{
	 				$this->ajaxReturn('2');
	 			}
	 		}else{
	 				$this->ajaxReturn('1');
	 		}
		}
	}
// $data['u_password'] = MD5($pass);